package com.kafak.springboot.springbootkafka.controller;

import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: ProducerController
 * Description:
 * date: 2023/3/12 17:28
 *
 * @author Yee
 * @since JDK 1.8
 */
@RestController
public class ProducerController {

    @Autowired
    KafkaTemplate<String,String> kafkaTemplate;

    /**
     * 发送kafka信息
     * @param msg
     * @return
     */
    @GetMapping("/testKafka")
    public String testKafka(String msg){
        kafkaTemplate.send("first",msg);
        return "ok";
    }
}
